package iterator;

import java.util.Iterator;

/**
 * 计算机学院迭代器
 */
public class ComputerCollegeIterator implements Iterator<Department> {

    private Department[] departments;
    // 遍历的位置
    private int position = 0;

    /**
     * 需要知道 Department 是以怎么样的方式存放的
     */
    public ComputerCollegeIterator(Department[] departments) {
        this.departments = departments;
    }

    @Override
    public boolean hasNext() {
        return position < departments.length && departments[position] != null;
    }

    @Override
    public Department next() {
        Department department = departments[position];
        position++;
        return department;
    }
}
